package com.cup.newSecurity.serviceImpl;

import com.cup.newSecurity.constant.LdapConstants;
import com.cup.newSecurity.util.LdapConnectionFactory;
import com.cup.newSecurity.util.LdapServer;
import com.novell.ldap.LDAPConnection;
import com.novell.ldap.LDAPEntry;
import com.novell.ldap.connectionpool.PoolManager;

public class MultiplePrivilegesRead {
	public static void main(String[] args) throws Exception {
		String userId = "tt";
		String instId = "0800010001";
		String userEntryDn = LdapConstants.UID + LdapConstants.EQUAL + userId + LdapConstants.FLAG
		+ LdapConstants.OU + LdapConstants.EQUAL + instId + LdapConstants.FLAG
		+ LdapConstants.INSTITUTE + LdapConstants.FLAG + LdapConstants.SEARCHBAKSE;
		PoolManager pm = LdapConnectionFactory.getInstance().getLdPool();
		LDAPConnection ld = pm.getBoundConnection(LdapServer.getInstance().getManager(), LdapServer.getInstance().getManagerPass().getBytes());
		LDAPEntry entry = ld.read(userEntryDn, new String[] {"privilege"});
		for(String s : entry.getAttribute("privilege").getStringValueArray()) {
			System.out.println(s);
		}
		
	}
}
